<template>
<div>
    <!-- <Form :label-width="75" :inline="true" :model="form" style="width:100%;background-color:rgba(220,220,220,0.7);padding-top:20px">
        <FormItem label="对接状态：">
            <Select v-model="form.abutment_status" clearable placeholder="请选择对接类别..." style="width:140px" >
                <Option value='0'>全部</Option>
                <Option value="1">约谈</Option>  
                <Option value="2">合作</Option>
                <Option value="3">完成</Option>
                <Option value="4">取消</Option>                  
            </Select>
        </FormItem>
        <FormItem label="发起者：">
            <Select v-model="form.sponsor" clearable placeholder="请选择发起者类别..." style="width:140px" >
                <Option value='0'>不限</Option>
                <Option value="demander">需求方发起</Option>
                <Option value="provider">服务方发起</Option>                    
            </Select>
        </FormItem>
        <FormItem label="编号：">
            <Input v-model="form.search_number" placeholder="请输入所查信息的编号" style="width:200px"/>
        </FormItem>
        <FormItem label="关键字：">
            <Input v-model="form.search" placeholder="请输入所查信息的标题或者关键字..." style="width:200px"/>
        </FormItem><br>
        <FormItem label="日期：">
            <DatePicker type="date" placeholder="从xx年xx月" v-model="form.begin_time" style="width:140px" ></DatePicker>
            <DatePicker type="date" placeholder="到xx年xx月" v-model="form.end_time" style="width:140px"></DatePicker>
       </FormItem>
        <Button type="primary" @click="handleSubmit()" style="margin-left:40px;margin-right:5px">查询</Button>
        <Button type="primary" @click="allinfo()" >所有历史对接信息</Button>
    </Form> -->
    <AutoQuery ref="auto-query" :query="query" :page="page"></AutoQuery>
    <AutoTable :columns="columns1" :data="abutment_list" :page="page"></AutoTable>
</div>
</template>
<script>
import Page from "@/common/model/Page";
import AutoTable from "@/common/components/AutoTable";
import AutoQuery from "@/common/components/AutoQuery";
import parent from "../Parent";
export default {
    extends:parent,
    components: {
        AutoTable,AutoQuery
    },
    home:'name',
    data () {
        var form = {
            sponsor:'0',
            search:"",
            search_number:"",      
            begin_time: '',
            end_time: '',
            abutment_status:'0'
        };
        return {
            page: new Page("search/abutment_item", this.formatItem(form)),
            form: form,
            query: { // 查询条件
                search_number: { type: "input", label: "编号：",placeholder: "请输入所查信息的编号" },
                search: { type: "input", label: "关键字：",placeholder: "请输入所查信息的标题或者关键字..." },
                abutment_status: { type: "select", label: "对接状态：", default: "0", placeholder: "请选择操作类别", options: [
                        { value: "0", label:  "全部" },
                        { value: "1", label: "约谈" },
                        { value: "2", label: "合作" },
                        { value: "3", label: "完成" },
                        { value: "4", label: "取消" },
                ] },
                sponsor: { type: "select", label: "发起者：", default: "0", placeholder: "请选择操作类别", options: [
                        { value: "0", label:  "不限" },
                        { value: "demander", label: "需求者" },
                        { value: "provider", label: "服务方" },
                ] },
                begin_time: { type: "date", label: "日期", placeholder: "选择开始时间" },
                end_time: { type: "date", placeholder: "选择截止时间", handleValue: value => { return value + 24*60*60*1000 } },
            },
            columns1: [
                {
                    title: '编号', render:(h, params) => {
                        return h('div', params.row.number);
                    }
                },
                {
                  title: '标题',
                  render: (h ,params) => {
                    return h('div',[
                      h('strong', params.row.title)
                    ])
                  }
                },
                {
                  title: '描述',
                  render: (h, params) => {
                    return h('div',[
                      h('strong', params.row.description)
                    ])
                  }
                },
                {
                  title: '发起者',
                  render: (h, params) => {
                     var sponsor = ({  
                            'provider': "服务方",
                            'demander': "需求方",                                               
                        })[params.row.sponsor];
                        return h('div', sponsor);
                    }
                },
                {
                  title: '需求方',
                  render: (h, params) => {
                    return h('div', [
                      h('strong', params.row.demand_enterprise)
                    ])
                  }
                },
                {
                  title: '需求方投递的项目',
                  render: (h, params) => {
                    return h('div', [
                      h('strong', params.row.demand_name)
                    ])
                  }
                },              
                {
                    title: '需求方状态',render: (h, params) => {        
                        var demand_status = ({  
                            '0': "未操作",
                            '1': "约谈",
                            '2': "合作",
                            '3': "完成",
                            '4': "取消",                       
                        })[params.row.demand_status];
                        return h('div', demand_status);
                    }
                },
                {
                  title:'服务方',
                  render: (h, params) => {
                    return h('div', [
                      h('strong', params.row.service_enterprise)
                    ])
                  }
                },
                {
                    title: '服务方发布的项目',
                    sortable: "custom",
                    key: 'create_time',
                    render: (h, params) => {
                        return h('div', params.row.service_name);
                    }
                },
                {
                    title: '服务方状态',render: (h, params) => {        
                        var service_status = ({
                            '0': "未操作",
                            '1': "约谈",
                            '2': "合作",
                            '3': "完成",
                            '4': "取消",                       
                        })[params.row.service_status];
                        return h('div', service_status);
                    }
                },
                {
                    title: '对接创建时间',
                    sortable: "custom",
                    key: 'create_time',
                    render: (h, params) => {
                        return h('div', new Date(parseInt(params.row.create_time)).toLocaleDateString()+" "+new Date(parseInt(params.row.create_time)).getHours()+":"+new Date(parseInt(params.row.create_time)).getMinutes());
                    }
                },
                // {
                //     title:'操作', width:150, align:'center', render:(h,params)=>{
                //     return h('div', [
                //         h('Button', {
                //         props: { type: 'primary', size: 'small' },
                //         style: { marginRight: '5px',display:this.showButton("111115") },
                //         on: { click: () => { this.delete(index) } }
                //         }, '删除')
                //     ]);}
                // }
            ],
        }
    },
    computed: {
        abutment_list(){
            return this.page.list;
        }, 
    },
    methods: {
        formatItem(data) {    
            return {
                abutment_status:data.abutment_status,
                sponsor:data.sponsor,
                search:data.search,
                search_number:data.search_number,
                begin_time: data.begin_time==""? "":Date.parse(new Date(data.begin_time)),
                end_time: data.end_time==""? "":Date.parse(new Date(data.end_time))+24*60*60*1000
            }
        },
        delete (index){
             this.$Modal.confirm({
                    title: '确认删除？',
                    content: '<p>继续删除，请点击确定按钮</p><br><p>取消，请点击取消按钮</p>',
                    onOk: () => {
                            this.api.post("feedback/delate_log",{ id: this.abutment_list[index].id}, res =>{
                            this.$CustomMessage.success('删除成功!');
                            this.page.getData();
                        })
                    },
                    onCancel: () => {
                        this.$CustomMessage.info('取消删除');
                    }
            });   
        }
    }
}
</script>
<style>
</style>